Skip to content

Update to Flutter Plugin V2 embedding; deprecate old methods for back… #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025

Conversation

MuhammedAm1n
Copy link
Contributor

✨ Flutter Background Location Tracker Plugin Modernization

This contribution modernizes the Flutter Background Location Tracker plugin by replacing deprecated Android and iOS patterns with the latest plugin APIs, ensuring compatibility with Flutter embedding v2 while maintaining backward support for existing applications.


🔧 Key Changes Implemented

Android Implementation

  • Updated BackgroundLocationTrackerPlugin.kt:

    • Migrated from Registrar, PluginRegistrantCallback, and ShimPluginRegistry to FlutterPlugin.FlutterPluginBinding.
    • Replaced PluginRegistrantCallback with a Kotlin lambda: (FlutterEngine) -> Unit.
    • Introduced a unified getFlutterEngine() method for consistent engine access.
    • Properly implemented onReattachedToActivityForConfigChanges() and onDetachedFromActivityForConfigChanges().
    • Deprecated legacy methods with @Deprecated annotations.
  • Refactored FlutterBackgroundManager.kt:

    • Removed all usage of ShimPluginRegistry.
    • Adopted the new getFlutterEngine() utility for engine access.

iOS Implementation

  • Enhanced SwiftBackgroundLocationTrackerPlugin.swift:

    • Replaced flutterPluginRegistrantCallback with an array of registrants (pluginRegistrants).
    • Updated engine initialization to loop through all registered registrants.
    • Created createMethodChannel(binaryMessenger:) for flexible channel creation.
  • Improved ForegroundChannel.swift:

    • Added createMethodChannel(binaryMessenger:) method.
    • Marked getMethodChannel(with:) as deprecated but retained it for backward compatibility.
  • Updated BackgroundLocationTrackerPlugin.m:

    • Added deprecation comments for clarity around older method usage.

Documentation & Examples

  • README.md Updates:

    • Added a Migration Guide section.
    • Clarified differences between old and new plugin APIs.
    • Explained embedding v2 patterns and rationale.
  • Example App Improvements:

    • Introduced a custom Application.kt in the Android example.
    • Annotated iOS AppDelegate.swift with V2 pattern examples.
    • Provided dual examples for legacy and modern plugin registration patterns.

ikbendewilliam
ikbendewilliam previously approved these changes May 19, 2025
… package_api_docs lint rule in analysis_options.yaml
@MuhammedAm1n
Copy link
Contributor Author

image

@ikbendewilliam ikbendewilliam merged commit 192b04a into icapps:master May 21, 2025
2 checks passed
@ikbendewilliam
Copy link
Contributor

Thank you for your PR! Apologies it took so long (I'm pretty busy, but tried to squeeze it in). It is now released as version 1.6.0 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants